package com.endoc.btmodule;

import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import java.util.ArrayList;
import java.util.List;

import cn.com.heaton.blelibrary.ble.model.BleDevice;

/**
 * @param <BleModel> 蓝牙相关ViewModel
 */
public abstract class BaseBleViewModel<BleModel extends com.endoc.btmodule.BleModel> extends ViewModel implements IBleCallBack {
    String TAG ="BaseBleViewModel";
    //蓝牙相关Model
   public BleModel bleModel;
    //搜索的设备
    public MutableLiveData<BleDevice> scanDeviceMutableLiveData = new MutableLiveData<BleDevice>();
    //搜索的设备集合
    public MutableLiveData<List<BleDevice>> scanDeviceListMutableLiveData = new MutableLiveData<List<BleDevice>>();

    public BaseBleViewModel() {
     bleModel = createModel();
     //设置当前为回调接口
     bleModel.setIBleCallBack(this);
    }

    public void initScanDeviceList(){
        //初始化集合
        scanDeviceListMutableLiveData.setValue(new ArrayList<BleDevice>());
    }

    //连接的设备
    public MutableLiveData<BleDevice> connectDeviceLiveData = new MutableLiveData<BleDevice>();
    //收到的数据
    public MutableLiveData<byte[]> receiveLiveData = new MutableLiveData<byte[]>();

    //可以开始写数据了
    public MutableLiveData<BleDevice> canWriteLiveData = new MutableLiveData<BleDevice>();

    //创建model
    public abstract BleModel createModel();



}
